﻿using PicoContainer;
using XEvolve.Core.Runtime;
using XEvolve.Core.Runtime.Attributes;
using XEvolve.Presentation;

namespace XEvolve.Chromatic
{
    [PluginId("xevolve.themes")]
    public class ThemesPlugin : Plugin
    {
        public ThemesPlugin([Required("xevolve.presentation")]Plugin[] dependencies) : base(dependencies)
        {
        }

        protected override void Initialize(Platform platform)
        {
            platform.Registry.RegisterTheme("XEvolve", @"/XEvolve.Chromatic;;;component\themes/xevolve.xaml");
            platform.Registry.RegisterThemeColorSchema("Default", @"/XEvolve.Chromatic;;;component\colorschema/xevolve/default.xaml", "XEvolve");
            platform.Registry.RegisterThemeColorSchema("Snow White", @"/XEvolve.Chromatic;;;component\colorschema/xevolve/snowwhite.xaml", "XEvolve");

            platform.RegisterService<DefaultThemeService, DefaultThemeService>();
        }
    }

    internal class DefaultThemeService : IStartable
    {
        private readonly IThemeManager themeManager;

        public DefaultThemeService(IThemeManager themeManager)
        {
            this.themeManager = themeManager;
        }

        public void Start()
        {            
            themeManager.ApplyTheme("XEvolve");
        }

        public void Stop()
        {         
        }
    }
}
